<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/jsp/include/taglib.jsp"%>
<%@ include file="/jsp/include/headlist.jsp"%>
<html>
<head>
	<title>版本管理</title>

<META http-equiv="x-ua-compatible" content="IE=8">

<script type="text/javascript">
		var refreshFlag = false;
		$(document).ready(function() {
			$("#searchForm").validate();
			
			$("#btnSubmit").click(function(){
				$("#searchForm").submit();
			});			
						
			$("#resetBut").click(function(){
				$(".ul-form input:text").not('.readonly').val("");
				$(".ul-form select").val("");
			});	
			
			$('.cancelButton').click(function(){
				$('#recordWindow').hide();
	        });

			window.onfocus = function(){
				if(refreshFlag){
					refreshFlag = false;
					$("#searchForm").submit();
				}
		  	};

		});
		
		function forceRefresh(){
			refreshFlag = true;
		}
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function delete1(id1){
			var id=id1;
			 var r=confirm("确定删除吗？")
				if(r){
					$.ajax({
						url : "${ctx}/version/"+id,
						type : 'delete',
						success: function(data, status, xhr) {
							alert("删除成功！");	
							$("#searchForm").submit();
							}, 
						error: function() {
							}
					});
				}
			 
		}
		
		function showAttach(id){
			$.jBox.open("iframe:${ctx}/jsp/attach/fileUpload.jsp?modelName=version&modelId="+id, "查看附件",600,300,{
				buttons:{"确定":true}, loaded:function(h){
					$(".jbox-content", document).css("overflow-y","hidden");
				}
			});
		}
	</script>
<style>
	.form-search .ul-form li label {
		width: 110px;
	}
	.table th, .table td {text-align:center}
	.t_l{text-align:left}
	.form-search INPUT[type='text'], .form-search SELECT{height:auto;}
	</style>
</head>
<body>
	<div class="f_window w570" id="recordWindow" name="recordWindow" style="display:none;">
	    <h3 class="clearfix mb10"><span class="fl" id="titleChange"></span>
	
	        <div class="fr close"><a class="cancelButton" href="javascript:void(0);">关闭窗口</a></div>
	    </h3>
	    <iframe style="display:inline;" scrolling="auto" height="150" frameborder="0" marginheight="0" marginwidth="0" width="100%" id="attachFrame" name="attachFrame" 
		  	src="${ctx}/jsp/attach/fileUpload.jsp?modelName=version&modelId=${version.id}"></iframe>
	</div>
	
	<form id="searchForm" action="${ctx}/version/list" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.currentPage}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input type="hidden" name="op" value="${op}" />
		<table class="ul-form" cellpadding="6">
			<tr ><td>标题：</td>
			<td><input type="text" name="title_l" maxlength="20" class="input-medium" value="${params.title_l}"/></td>
			
			<td>上传时间：</td>
			<td><input type="text" name="uploadDate_s" class="hasDatepicker" onClick="WdatePicker()" value="${params.uploadDate_s}"/>
			<td>至<input type="text" name="uploadDate_e" class="hasDatepicker" onClick="WdatePicker()" value="${params.uploadDate_e}"/>
			</td>
			</tr>
			<tr>
			<td>稿件版本：</td>
			<td>
			<input type="text" name="version_l" maxlength="10" class="input-medium" value="${params.version_l}"/>
			<td>上传单位：</td>
			<td><input type="text" name="unit_l" maxlength="50" class="input-medium" value="${params.unit_l}"/>
			</td>
			<td>稿件类型：
		      <select name="type" class="input-medium-select creset">
		        <c:forEach items="${fields.type.option}" var="op">
		          <option value="${op.key}" ${op.key==params.type ? 'selected':''}>${op.value}</option>
		        </c:forEach>
		      </select>			
			</td>			
			<td>修志类别：</td>
		     <td> <select name="chronType" class="input-medium-select creset">
		        <c:forEach items="${fields.chronType.option}" var="op">
		          <option value="${op.key}" ${op.key==params.chronType ? 'selected':''}>${op.value}</option>
		        </c:forEach>
		      </select>			
			</td>						
			<td class="clearfix"></td>
			</tr>			
		</table>
		<div class="input01"><a id="btnSubmit" href="javascript:void(0)">查询</a><a id="resetBut" href="javascript:void(0)">重置</a></div>		
	</form>
	<div class="wd-butbar">
	<div class="top-a">
	<a class="a01" href="${ctx}/version/add" target="_blank" onclick="forceRefresh()">新增版本</a>
	</div>
	</div>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr><th>序号</th>
				<th>标题</th>
				<th>修志类别</th>
				<th>稿件版本</th>
				<th>稿件类型</th>
				<th>上传时间</th>
				<th>上传人员</th>
				<th>所属单位</th>
				<th>文档</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${list}" var="version"  varStatus="rownum" >
			<tr>
				<td style="text-align: center;">${rownum.count}</td>
				<td>
					${version.title}
				</td>
				<td>
					${fields.chronType.option[version.chronType]}
				</td>
				<td>
					${version.version}
				</td>
				<td>
					${fields.type.option[version.type]}
				</td>
				<td>
					${version.uploadDate}
				</td>				
				<td>
					${version.uploader}
				</td>				
				<td>
					${version.unit}
				</td>								
				<td>
					<a href="javascript:void(0);" onclick="showAttach(${version.id})">附件</a>
				</td>		
				<td>
					<a href="${ctx}/version/view?id=${version.id}" target="_blank">查看</a>
					<a href="${ctx}/version/edit?id=${version.id}" target="_blank" onclick="forceRefresh()">修改</a>
					<a href="javascript:void(0)" onclick="delete1(${version.id})">删除</a>
				</td>						
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${pagination}</div>
</body>
</html>